DR2='Q:'
F1='ACT_PRO2'
f2='revenue2'
f21='REVDAT2X'
SELE 1
SET EXCLU OFF
USE &DR2&F1
sele 2
set exclu off
use &dr2&f2 index &dr2&f21
GO TOP
MON=CMONTH(DATE_VISIT)
STORE 0 TO TOTFEE,TOTGROSS,TOTAX,TOTGROSSI,TOTAXI,TOTNET,totneti,PAG,fl,hl,ttl,ttl1,PROC,pl1,pl2,pl3
tanggal=date()
do while pl1=0
   @ 12,60 say '/'
   @ 12,54 prompt 'Print'
   @ 12,62 prompt 'Quit'
   menu to pl1
   if pl1=2
      RETN=.T.
      return
   else
      @ 14,60 say '/'
      @ 14,46 prompt 'Printer Ready'
      @ 14,62 prompt 'Not Yet Ready'
      menu to pl2
      if pl2=2
         @ 14,46 clea to 14,78
         pl1=0
      else
         @ 16,46 say '        Printing...    '
         set console off
         set devi to prin
      endif
   endif
enddo
br=100
set devi to print
@ 0,0 say chr(15) pict 'x'
SELE 1
USE &DR2&F1
GO TOP
XR='N'
ppag=pag
PAG=PAG+1
DO WHILE .NOT. EOF()
   if br>66
      if fl>0
         eject
      else
         fl=1
      endif
      cl=50
      hl=hl+1
      @  1, 44 SAY CHR(27)+'G'
      @  1, 44 say 'S. O. S.  M E D I K A'
      @  1, 44 SAY CHR(27)+'H'
      if pag=1
         @  3, 26 SAY 'Schedule of fees of HEALTH & FITNESS for the month of '+MON
         @  5,  4 say "Page "+STR(PAG)
         @  5, 64 say "issued on "+dtoc(date())
      else
         @  3, 6 SAY 'Schedule of fees of HEALTH & FITNESS for the month of '+MON+'    Continued from page '+ltrim(str(PPAG))
         @ 5,  4 say "Page "+ltrim(STR(PAG))
         @ 5, 64 say "issued on "+dtoc(date())
      endif
      br=8
      @ br,  2 say "INVOICE"
      @ br, 12 say "DATE OF"
      @ br, 30 say "P A T I E N T"
      @ br, 59 say "P R O C E D U R E"
      @ BR, 89 SAY "NBER"
      @ br, 96 say "UNIT"
      @ BR,106 SAY "TOTAL"
      @ br,117 say "GROSS"
      @ BR,127 SAY "TAX"
      @ BR,133 SAY "NET"
      BR=BR+1
      @ BR,  3 SAY "Nber."
      @ BR, 12 SAY "VISIT"
      @ BR, 22 SAY "CODE"
      @ BR, 28 SAY "NAME & FIRST NAME"
      @ BR, 59 SAY "CODE"
      @ BR, 65 SAY "DESCRIPTION"
      @ BR, 96 SAY "PRICE"
      @ BR,106 SAY "PRICE"
      @ BR,118 SAY "FEE"
      @ BR,126 SAY "PPH 21"
      @ BR,133 SAY "FEE"
      IF PAG>1
         BR=BR+2
         ttl1=0
         @ BR,  2 SAY "Carried forward from page"
         @ BR, 28 say ppag  pict "99"
         @ br, 30 say repl(chr(46),99)
         DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*         @ BR,129 say ttl PICT "99,999,999"
      ENDIF
      BR=BR+2
      do while BR<56
         IF AREA_CODE='H' .AND. SUB_AREACO<>'6'
            HF='Y'
            PUBPRIC=PUB_PRICE
            TOTPRIC=PUB_PRICE*PROC_X
         ELSE
            if eof()
               exit
            else
               SKIP
               LOOP
            endif
         ENDIF
         IF HF='Y'
            inv=dtos(date_visit)+inv_nber
            FEE=TOTPRIC*.52
            TAX=TOTPRIC*.06
            NET=FEE-TAX
            @ BR,  0 SAY PROC   PICT "999"
            @ BR,  4 SAY right(INV,5)
            @ BR, 12 SAY DTOC(DATE_VISIT)
            @ BR, 22 SAY PAT_FILCOD
            SELE 2
            SEEK INV
            @ BR, 30 SAY TRIM(PAT_NAME)+' '+PAT_F_NAME
            SELE 1
            @ BR, 59 SAY AREA_CODE+SUB_AREACO+PRO_CODE
            @ BR, 65 SAY SHRT_DESCR
            @ BR, 89 SAY PROC_X      pict "99"
            IF PUBPRIC<>0
             DO SAYG WITH BR,93,PUBPRIC,'99,999.99','9,999,999'
*             @ BR, 93 SAY PUBPRIC     pict "9,999,999"
            ELSE
               @ BR, 96 SAY "N / A"
            ENDIF
            DO SAYG WITH BR,103,TOTPRIC,'99,999.99','9,999,999'
            DO SAYG WITH BR,113,FEE,'99,999.99','9,999,999'
            DO SAYG WITH BR,123,TAX,'999.99','99,999'
            DO SAYG WITH BR,130,NET,'99,999.99','9,999,999'
*            @ BR,103 SAY TOTPRIC     pict "9,999,999"
*            @ BR,113 SAY FEE         pict "9,999,999"
*            @ BR,123 SAY TAX         pict "99,999"
*            @ BR,130 SAY NET         pict "9,999,999"
            TTL=TTL+NET
            TTL1=TTL1+NET
            TOTGROSS=TOTGROSS+FEE
            TOTAX=TOTAX+TAX
            TOTGROSSI=TOTGROSSI+FEE
            TOTAXI=TOTAXI+TAX
            TOTNET=TOTNET+NET
            TOTNETI=TOTNETI+NET
            PROC=PROC+1
            BR=BR+2
            SKIP
            LOOP
         else
            skip
            loop
         ENDIF
      enddo
      if eof()
         exit
      else
         @ BR,  2 SAY "Total, this page"
         @ br, 19 say repl(chr(46),110)
         DO SAYG WITH BR,130,TTL1,'99,999.99','9,999,999'
*         @ br,130 say ttl1 pict "9,999,999"
         br=br+2
         @ BR,  2 SAY "Total to be carried forward"
         @ br, 30 say repl(chr(46),99)
         DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*         @ br,129 say ttl pict "99,999,999"
         br=100
         ppag=pag
         pag=pag+1
         LOOP
      endif
   ENDIF
ENDDO
do while .t.
   if br<56
      @ BR,  2 SAY "Total, this page"
      @ br, 19 say repl(chr(46),110)
      DO SAYG WITH BR,130,TTL,'99,999.99','9,999,999'
*      @ br,130 say ttl1 pict "9,999,999"
      br=br+2
      @ BR,  2 SAY "Grand Total"
      @ br, 14 say repl(chr(46),115)
      DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*      @ br,129 say ttl pict "99,999,999"
      br=br+2
      @ br, 12 say "TOTAL PAYABLE TO HEALTH & FITNESS PRACTITIONER : "
      DO SAYG WITH BR,61,TTL,'999,999.99','99,999,999'
*      @ BR, 61  SAY TTL PICT "99,999,999"
      @ BR, 72  SAY "Rupiah"
      br=br+2
      @ BR, 12 SAY "For information ==>> Gross :"
      DO SAYG WITH BR,44,TOTGROSSI,'999,999.99','99,999,999'
*      @ BR, 44 say totgrossi pict "99,999,999"
      @ Br, 55 say "Rupiah, less Tax (PPH21) :"
      DO SAYG WITH BR,82,TOTAXI,'99,999.99','9,999,999'
*      @ br, 82 say totaxi pict "9,999,999"
      @ br, 92 say "Rupiah"
      br=br+2
      BR=100
      exit
   else
      eject
      br=0
      loop
   endif
enddo
br=100
PAG=0
fl=0
hl=0
ttl=0
ttl1=0
GO TOP
totgrossi=0
totaxi=0
totneti=0
ttl=0
ttl1=0
PROC=0
XR='N'
ppag=pag
PAG=PAG+1
DO WHILE .NOT. EOF()
   if br>66
      if fl>0
         eject
      else
         fl=1
      endif
      cl=50
      hl=hl+1
      @  1, 44 SAY CHR(27)+'G'
      @  1, 44 say 'S. O. S.  M E D I K A'
      @  1, 44 SAY CHR(27)+'H'
      if pag=1
         @  3, 26 SAY 'Schedule of fees of MASSAGE THERAPY for the month of '+MON
         @  5,  4 say "Page "+STR(PAG)
         @  5, 64 say "issued on "+dtoc(date())
      else
         @  3, 6 SAY 'Schedule of fees of MASSAGE THERAPY for the month of '+MON+'    Continued from page '+ltrim(str(PPAG))
         @ 5,  4 say "Page "+ltrim(STR(PAG))
         @ 5, 64 say "issued on "+dtoc(date())
      endif
      br=8
      @ br,  2 say "INVOICE"
      @ br, 12 say "DATE OF"
      @ br, 30 say "P A T I E N T"
      @ br, 59 say "P R O C E D U R E"
      @ BR, 89 SAY "NBER"
      @ br, 96 say "UNIT"
      @ BR,106 SAY "TOTAL"
      @ br,117 say "GROSS"
      @ BR,127 SAY "TAX"
      @ BR,133 SAY "NET"
      BR=BR+1
      @ BR,  3 SAY "Nber."
      @ BR, 12 SAY "VISIT"
      @ BR, 22 SAY "CODE"
      @ BR, 28 SAY "NAME & FIRST NAME"
      @ BR, 59 SAY "CODE"
      @ BR, 65 SAY "DESCRIPTION"
      @ BR, 96 SAY "PRICE"
      @ BR,106 SAY "PRICE"
      @ BR,118 SAY "FEE"
      @ BR,126 SAY "PPH 21"
      @ BR,133 SAY "FEE"
      IF PAG>1
         BR=BR+2
         ttl1=0
         @ BR,  2 SAY "Carried forward from page"
         @ BR, 28 say ppag  pict "99"
         @ br, 30 say repl(chr(46),99)
         DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*         @ BR,129 say ttl PICT "99,999,999"
      ENDIF
      BR=BR+2
      do while BR<56
         IF AREA_CODE='H' .AND. SUB_AREACO='6'
            HF='Y'
            PUBPRIC=PUB_PRICE
            TOTPRIC=PUB_PRICE*PROC_X
         ELSE
            if eof()
               exit
            else
               SKIP
               LOOP
            endif
         ENDIF
         IF HF='Y'
            inv=dtos(date_visit)+inv_nber
            FEE=TOTPRIC*.52
            TAX=TOTPRIC*.06
            NET=FEE-TAX
            @ BR,  0 SAY PROC   PICT "999"
            @ BR,  4 SAY right(INV,5)
            @ BR, 12 SAY DTOC(DATE_VISIT)
            @ BR, 22 SAY PAT_FILCOD
            SELE 2
            SEEK INV
            @ BR, 30 SAY TRIM(PAT_NAME)+' '+PAT_F_NAME
            SELE 1
            @ BR, 59 SAY AREA_CODE+SUB_AREACO+PRO_CODE
            @ BR, 65 SAY SHRT_DESCR
            @ BR, 89 SAY PROC_X      pict "99"
            IF PUBPRIC<>0
               DO SAYG WITH BR,93,PUBPRIC,'99,999.99','9,999,999'
*               @ BR, 93 SAY PUBPRIC     pict "9,999,999"
            ELSE
               @ BR, 96 SAY "N / A"
            ENDIF
            DO SAYG WITH BR,103,TOTPRIC,'99,999.99','9,999,999'
            DO SAYG WITH BR,113,FEE,'99,999.99','9,999,999'
            DO SAYG WITH BR,123,TAX,'999.99','99,999'
            DO SAYG WITH BR,130,NET,'99,999.99','9,999,999'
*            @ BR,103 SAY TOTPRIC     pict "9,999,999"
*            @ BR,113 SAY FEE         pict "9,999,999"
*            @ BR,123 SAY TAX         pict "99,999"
*            @ BR,130 SAY NET         pict "9,999,999"
            TTL=TTL+NET
            TTL1=TTL1+NET
            TOTGROSS=TOTGROSS+FEE
            TOTAX=TOTAX+TAX
            TOTGROSSI=TOTGROSSI+FEE
            TOTAXI=TOTAXI+TAX
            TOTNET=TOTNET+NET
            TOTNETI=TOTNETI+NET
            PROC=PROC+1
            BR=BR+2
            SKIP
            LOOP
         else
            skip
            loop
         ENDIF
      enddo
      if eof()
         exit
      else
         @ BR,  2 SAY "Total, this page"
         @ br, 19 say repl(chr(46),110)
         DO SAYG WITH BR,130,TTL1,'99,999.99','9,999,999'
*         @ br,130 say ttl1 pict "9,999,999"
         br=br+2
         @ BR,  2 SAY "Total to be carried forward"
         @ br, 30 say repl(chr(46),99)
         DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*         @ br,129 say ttl pict "99,999,999"
         br=100
         ppag=pag
         pag=pag+1
         LOOP
      endif
   ENDIF
ENDDO
br=br+2
do while .t.
   if br<56
      @ BR,  2 SAY "Total, this page"
      @ br, 19 say repl(chr(46),110)
      DO SAYG WITH BR,130,TTL1,'99,999.99','9,999,999'
*      @ br,130 say ttl1 pict "9,999,999"
      br=br+2
      @ BR,  2 SAY "Grand Total"
      @ br, 14 say repl(chr(46),115)
      DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*      @ br,129 say ttl pict "99,999,999"
      br=br+2
      @ br, 12 say "TOTAL PAYABLE TO MASSAGE THERAPY PRACTITIONER : "
      DO SAYG WITH BR,60,TTL,'999,999.99','99,999,999'
*      @ BR, 60  SAY TTL PICT "99,999,999"
      @ BR, 71  SAY "Rupiah"
      br=br+2
      @ BR, 12 SAY "For information ==>> Gross :"
      DO SAYG WITH BR,44,TOTGROSSI,'999,999.99','99,999,999'
*      @ BR, 44 say totgrossi pict "99,999,999"
      @ Br, 55 say "Rupiah, less Tax (PPH21) :"
      DO SAYG WITH BR,82,TOTAXI,'99,999.99','9,999,999'
*      @ br, 82 say totaxi pict "9,999,999"
      @ br, 92 say "Rupiah"
      br=br+2
      BR=100
      exit
   else
      eject
      br=0
      loop
   endif
enddo
@ 0,0 say chr(15) pict 'x'
SET DEVI TO SCREEN
CLOSE DATA
CLOSE INDEX
RETURN



